<!DOCTYPE html>
<head>
    <title>ECharts</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<style type="text/CSS">
      div {background-color: transparent}
	</style>
    <!-- ECharts单文件引入 -->
    <script src="js/echarts.js"></script>
    <script type="text/javascript">
    var option;
    var myChart;
    function echartViewAction(param) {
        if (typeof param.seriesIndex != 'undefined') {
            document.location.href = 'pyEchartAction://' + param.type + '#{"seriesIndex":"' +  + param.seriesIndex + '","dataIndex":"' + param.dataIndex + '"}';
        } else {
            document.location.href = 'pyEchartAction://' + param.type;
        }
    }
    function preTask(obj) {
        var result;
        if(typeof(obj) == 'object') {
            if(obj instanceof Array) {
                result = new Array();
                for (var i = 0, len = obj.length; i < len ; i++) {
                     result.push(preTask(obj[i]));
                }
                return result;
            } else if(obj instanceof RegExp){
                return obj;
            } else {
                result = new Object();
                for (var prop in obj) {
                    result[prop] = preTask(obj[prop]);
                }
                return result;
            }
        } else if(typeof(obj) == 'string'){
            try {
                if(typeof(eval(obj)) == 'function'){
                    return eval(obj);
                } else if (typeof(eval(obj) == 'object') && (eval(obj) instanceof Array || eval(obj) instanceof CanvasGradient)) {
                    return eval(obj);
                }
            }catch(e) {
                return obj;
            }
            return obj;
        } else {
            return obj;
        }
    }
	/**  
	 * 构建动态图表  
	 * @param url   获取后台数据地址  
	 * @param time  图表查询时间  
	 * @param elem  加载容器  
	 */  
	function loadEcharts(testdate){
		// 路径配置
        require.config({
            paths: {
                echarts: 'js'
            }
        });
        
        // 使用
        require(
            [
                'echarts',
                'echarts/chart/line', // 使用柱状图就加载line模块，按需加载
                'echarts/chart/bar',
                'echarts/chart/pie',
                'echarts/chart/k',
                'echarts/chart/scatter'
            ],
            function (ec) {
                // 基于准备好的dom，初始化echarts图表
                myChart = ec.init(document.getElementById('main'));
                option = preTask(testdate);
                //option = preTask(testdate);
                // 为echarts对象加载数据
                myChart.setOption(option);
            }
        );
	}
    function resizeDiv(cssText) {
        var divMain = document.getElementById("main");
        divMain.style.cssText = cssText;
    }
    function initEchartView() {
        // 路径配置
        require.config({
            paths: {
                echarts: 'js'
            }
        });
        // 使用
        require(
            [
                'echarts',
                'echarts/chart/line', // 使用柱状图就加载line模块，按需加载
                'echarts/chart/bar',
                'echarts/chart/pie',
                'echarts/chart/k',
                'echarts/chart/scatter'
            ],
            function (ec) {
                var ecConfig = require('echarts/config');
                // 基于准备好的dom，初始化echarts图表
                myChart = ec.init(document.getElementById('main'));
                
                // 为echarts对象加载数据
                myChart.setOption(option);
                myChart.on(ecConfig.EVENT.CLICK, echartViewAction);
                myChart.on(ecConfig.EVENT.DBLCLICK, echartViewAction);
                myChart.on(ecConfig.EVENT.DATA_ZOOM, echartViewAction);
                myChart.on(ecConfig.EVENT.LEGEND_SELECTED, echartViewAction);
                myChart.on(ecConfig.EVENT.MAGIC_TYPE_CHANGED, echartViewAction);
                myChart.on(ecConfig.EVENT.DATA_VIEW_CHANGED, echartViewAction);
            }
        );
    }
    </script>
</head>
<body style="background-color: transparent"><!-- transparent-->
    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
    <div id="main" style="height:270px;width:420px;" ></div><!-- style="height:270px;width:420px;margin-left:-30px;"-->
</body>
